import java.util.Scanner;

public class SpanPie {
    public static void main(String[] args) {
//        输入与输出
        Scanner scanner = new Scanner(System.in);
        int row = scanner.nextInt();
        int col = scanner.nextInt();
        int[][] map = new int[row][col];
        for (int i = 0; i < row; i++) {
            for (int j = 0; j < col; j++) {
                map[i][j] = scanner.nextInt();
            }
        }
        //输出map
        System.out.println(fun(map));
    }

    public static int fun(int[][] map) {
        if (map == null || map.length == 0 || map[0] == null || map[0].length == 0) {
            return 0;
        }
        int sum = 0;
        for (int i = 0; i < map.length; i++) {
            int oneMax = Integer.MIN_VALUE;
            for (int j = 0; j < map[0].length; j++) {
                oneMax = Math.max(oneMax, map[i][j]);
            }
            sum += oneMax;
        }
        return sum;
    }

}
